3D Graphics Programming with QuickDraw 3D 1.5.4
Previous | QD3D Book | Overview | Chapter Contents | Next |
The 3D Viewer provides a number of functions that you can use to get and set information about a viewer object and to manage its states.
You can use the Q3ViewerGetVersion function to get the version of the 3D Viewer.
OSErr Q3ViewerGetVersion (
unsigned long *majorRevision,
unsigned long *minorRevision);
TQ3Status Q3WinViewerGetVersion(
unsigned long *majorRevision,
unsigned long *minorRevision);
You can use the Q3ViewerGetReleaseVersion function to get the release version number of the 3D Viewer.
You can use the Q3ViewerGetView function to get the view object associated with a viewer object.
You can use the Q3ViewerRestoreView function to restore the camera associated with a viewer object.
The Q3ViewerRestoreView function restores the camera settings of the viewer specified by the theViewer parameter to the original camera specified in the associated view hints object. If there is no view hints object associated with the specified viewer, Q3ViewerRestoreView creates a new default camera.
Q3ViewerRestoreView performs the same operations as the reset button in the controller strip.
You can use the Q3ViewerGetCameraCount function to determine how many camera objects are currently associated with a viewer object.
TQ3Status Q3WinViewerGetCameraCount (
TQ3ViewerObject viewer,
unsigned long *count );
The Q3ViewerGetCameraCount function returns, in the unsigned long integer pointed to by the cnt parameter, the number of camera objects associated with the viewer object specified by the theViewer parameter. If there is no view hints object associated with that viewer object, then there are no camera associated with that viewer object and Q3ViewerGetCameraCount returns 0.
Q3ViewerGetCameraCount counts only cameras of type kQ3CameraViewAngleAspect .
You can use the Q3ViewerSetCameraByNumber function to set a viewer's camera to a camera specified by its index in the list of the viewer's cameras.
OSErr Q3ViewerSetCameraByNumber (
TQ3ViewerObject theViewer,
unsigned long cameraNo);
TQ3Status Q3WinViewerSetCameraNumber (
TQ3ViewerObject viewer,
unsigned long cameraNo );
The Q3ViewerSetCameraByNumber function sets the camera of the viewer object specified by the theViewer parameter to the camera whose index in the list of the viewer's cameras is cameraNo .
Q3ViewerSetCameraByNumber performs the same operations as the camera viewpoint pop-up menu in the controller strip.
You can use the Q3ViewerSetCameraByView function to set a camera to a predefined camera view.
OSErr Q3ViewerSetCameraByView (
TQ3ViewerObject theViewer,
TQ3ViewerCameraView viewType);
TQ3Status Q3WinViewerSetCameraView (
TQ3ViewerObject viewer,
TQ3ViewerCameraView viewType );
The Q3ViewerSetCameraByView function sets the camera of the viewer object specified by the theViewer parameter to the camera viewpoint specified by the viewType parameter. For instance, if the value of the viewType parameter is kQ3ViewerCameraTop , then Q3ViewerSetCameraByView sets the camera to a viewpoint that is directly above the model in the viewer object.
You can use the Q3ViewerGetFlags function to get the current viewer flags for a viewer object.
You can use the Q3ViewerSetFlags function to set the viewer flags for a viewer object.
You can use the Q3ViewerGetBounds function to get the rectangle that bounds a viewer's pane.
You can use the Q3ViewerSetBounds function to set the rectangle that bounds a viewer's pane.
The Q3ViewerSetBounds function sets the bounds of the viewer pane of the viewer object specified by the theViewer parameter to the rectangle specified by the bounds parameter.
Any changes to a viewer's bounds will not be visible until you call Q3ViewerDraw with the specified viewer object.
You can use the Q3ViewerGetMininumDimension function to get the sides of the smallest rectangle that can contain the controller strip of a viewer object.
OSErr Q3ViewerGetMininumDimension (
TQ3ViewerObject theViewer,
unsigned long *width,
unsigned long *height);
TQ3Status Q3WinViewerGetMinimumDimension (
TQ3ViewerObject viewer,
unsigned long *width,
unsigned long *height );
The Q3ViewerGetMininumDimension function returns, in the width and height parameters, the width and height of the minimum viewer pane required to contain the entire contents of the controller strip associated with the viewer object specified by the theViewer parameter. If your application allows the viewer pane to be resized, you should ensure that it is not sized smaller than the dimensions returned by Q3ViewerGetMininumDimension ; otherwise, some of the buttons in the controller strip will be clipped.
You can use the Q3ViewerGetPort function to get the Macintosh graphics port associated with a viewer object. This function has no equivalent in the Windows environment.
CGrafPtr Q3ViewerGetPort (TQ3ViewerObject theViewer);
The Q3ViewerGetPort function returns, as its function result, a pointer to the port currently associated with the viewer object specified by the theViewer parameter. The returned pointer may be a a pointer to a color graphics port, a pointer to an offscreen graphics world, or the value NULL , indicating that no port is currently associated with the viewer object.
You can use the Q3ViewerSetPort function to set the graphics port associated with a viewer object. This function has no equivalent in the Windows environment.
OSErr Q3ViewerSetPort (TQ3ViewerObject theViewer, CGrafPtr port);
You can use the Q3ViewerGetGroup function to get the group of objects currently associated with a viewer.
The Q3ViewerGetGroup function returns, as its function result, a reference to the group containing the objects currently associated with the viewer specified by the theViewer parameter. The reference count of that group is incremented. You should therefore dispose of the group when you have finished using it.
You can use the Q3ViewerUseGroup function to set the group of objects associated with a viewer.
You can use the Q3ViewerGetState function to get the current state of a viewer object.
The Q3ViewerGetState function returns a long integer that encodes information about the current state of the viewer object specified by the theViewer parameter. Bits of the returned long integer are addressed using these constants, which define the viewer state flags:
enum {
kQ3ViewerEmpty = 0,
kQ3ViewerHasModel = 1<<0,
kQ3ViewerHasUndo = 1<<1
};
If Q3ViewerGetState returns the value kQ3ViewerEmpty , there is no image currently displayed by the specified viewer object. If Q3ViewerGetState returns the value kQ3ViewerHasModel , there is an image currently displayed by the specified viewer object. If Q3ViewerGetState returns the value kQ3ViewerHasUndo , the user has modified the camera state using the interactive controls. You can use this information to determine whether Edit menu commands such as Undo, Cut, Clear, and Copy should be enabled or disabled.
You can use the Q3ViewerGetUndoString function to get a string that describes the most recent user operation that can be undone.
Boolean Q3ViewerGetUndoString (
TQ3ViewerObject theViewer,
char *string,
unsigned long *cnt);
TQ3Boolean Q3WinViewerGetUndoString (
TQ3ViewerObject viewer,
char *string,
unsigned long stringSize,
unsigned long *actualSize );
The Q3ViewerGetUndoString function returns, through the string parameter, a localized string that describes the most recent user action in the viewer specified by the theViewer parameter that can be undone.
Q3ViewerGetUndoString also returns, as its function result, a Boolean value that indicates whether you can call the Q3ViewerUndo function to perform the undo operation ( TRUE ) or not ( FALSE ).
Typically, you'll use the string returned by Q3ViewerGetUndoString to generate the text for the Undo menu item in the Edit menu. Note, however, that the string returned through the string parameter does not contain the substring "Undo." You should get the appropriate substring (perhaps from a resource) and conjoin it with the string returned by Q3ViewerGetUndoString to construct the menu item text.
You can use the Q3ViewerGetPict function to get a Macintosh 'pict' representation of the image currently displayed by a viewer object. This function has no equivalent in the Windows environment.
PicHandle Q3ViewerGetPict (TQ3ViewerObject theViewer);
The Q3ViewerGetPict function returns, as its function result, a handle to a Macintosh 'pict' structure that contains a representation of the image currently displayed by the viewer object specified by the theViewer parameter. You should call DisposeHandle to dispose of the memory occupied by the pict when you're done using it.
You can use the Q3ViewerGetButtonRect function to get the rectangle that encloses a viewer button.
OSErr Q3ViewerGetButtonRect (
TQ3ViewerObject theViewer,
unsigned long button,
Rect *rect);
TQ3Status Q3WinViewerGetButtonRect (
TQ3ViewerObject viewer,
unsigned long button,
RECT *rectangle );
The Q3ViewerGetButtonRect function returns, in the rect parameter, the rectangle that encloses the button specified by the button parameter in the viewer object specified by the theViewer parameter. You can use these constants to specify the button whose rectangle you want returned:
kQ3ViewerButtonCamera
kQ3ViewerButtonTruck
kQ3ViewerButtonOrbit
kQ3ViewerButtonZoom
kQ3ViewerButtonDolly
kQ3ViewerButtonReset
You can use the Q3ViewerGetCurrentButton function to get the active button of a viewer.
You can use the Q3ViewerSetCurrentButton function to set the active button of a viewer pane.
TQ3Status Q3WinViewerSetCurrentButton (
TQ3ViewerObject viewer,
unsigned long button );
The Q3ViewerSetCurrentButton function sets the active button of the viewer object specified by the theViewer parameter to the button specified by the button parameter. You can use these constants to specify a button:
kQ3ViewerButtonTruck
kQ3ViewerButtonOrbit
kQ3ViewerButtonZoom
kQ3ViewerButtonDolly
You can use the Q3ViewerGetDimension function to get the current dimensions of the model space in a viewer's view hints object.
OSErr Q3ViewerGetDimension (
TQ3ViewerObject theViewer,
unsigned long *width,
unsigned long *height);
TQ3Status Q3WinViewerGetDimension (
TQ3ViewerObject viewer,
unsigned long *width,
unsigned long *height );
The Q3ViewerGetDimension function returns, in the width and height parameters, the current width and height of the model space in the view hints object associated with the viewer object specified by the theViewer parameter. If there is no such view hints object, Q3ViewerGetDimension returns the width and height of the viewer pane.
You can use the Q3ViewerSetDimension function to set the current dimensions of the model space in a viewer's view hints object.
OSErr Q3ViewerSetDimension (
TQ3ViewerObject theViewer,
unsigned long width,
unsigned long height);
TQ3Status Q3WinViewerSetDimension (
TQ3ViewerObject viewer,
unsigned long width,
unsigned long height );
You can use the Q3ViewerGetBackgroundColor function to get the background color of a viewer.
You can use the Q3ViewerSetBackgroundColor function to set the background color of a viewer.
Previous | QD3D Book | Overview | Chapter Contents | Next |